package com.yinhe.music.yhmusic.autolisten;

import com.yinhe.music.yhmusic.base.BaseModel;
import com.yinhe.music.yhmusic.base.BasePresenter;
import com.yinhe.music.yhmusic.network.response.ResponseTransformer;

public class AutoListenPresenter extends BasePresenter<BaseModel, AutoListenContract.IAutoListenView> implements AutoListenContract.IAutoListenPresenter {
    @Override
    public void getSongClassify() {
        if (getView() == null) {
            return;
        }

        addSubscription(mModel.getSongClassify()
                .compose(ResponseTransformer.handleResult())
                .compose(schedulerProvider.applySchedulers())
                .subscribe(langResp -> {
                    getView().setSongClassifyUI(langResp.songClassifyList);
                }, throwable -> {
                    getView().showMessage(throwable);
                }));
    }

    @Override
    public void getClassifySongs(int classifyId) {
        if (getView() == null) {
            return;
        }

        addSubscription(mModel.getClassifySongs(classifyId)
                .compose(ResponseTransformer.handleResult())
                .compose(schedulerProvider.applySchedulers())
                .subscribe(music -> {
                    getView().setSongListUI(music.getSongList());
                }, throwable -> {
                    getView().showMessage(throwable);
                }));
    }
}
